home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
148_01
/
a99.gbl
< prev
next >
Wrap
Text File
|
1987-09-26
|
5KB
|
182 lines
/*
TMS990 Series Cross-Assembler v. 1.0
January, 1985
Copyright (c) 1980 William C. Colley, III.
Modified for the 990 Series by Alexander Cameron.
File: a99.gbl
Global macro substitutions and external variable declarations.
*/
/* Set input line length: */
#define LINLEN 120
/* Define disk buffer parameters: */
#define NSECT 32
/* Define symbol table parameters: */
#define SYMLEN 8 /* Length of labels (must be an even number). */
#define SYMBOLS 599 /* Number of symbols in symbol table. */
#define PADDING " " /* SYMLEN - 1 blanks. */
/* Number of if statements that can be nested: */
#define IFDEPTH 16
/* BDOS functions called directly: */
#define LISTOUT 5 /* Put character to list device. */
#define LOGDISK 14 /* Log in disk drive. */
#define GETDISK 25 /* Get currently logged in disk. */
/* Define flag values: */
#define TRUE 1 /* General use. */
#define FALSE 0
#define SKIP TRUE /* Used with skip flag in getchr. */
#define NOSKIP FALSE
#define BIGST TRUE /* Used to tell kind of string in getitem. */
#define SMALST FALSE
#define NOCODE 0 /* Used to tell the hex generator what to do. */
#define PUTCODE 1
#define FLUSH 2
#define NOMORE 3
/* File descriptors: */
#define LODISK 0 /* Lowest numbered disk. */
#define NOFILE -1 /* No file specified. */
#define CONO -2 /* Console output. */
#define LST -3 /* List device. */
/* Items can have the following attributes: */
#define ALPHA 0 /* Alphabetic character. */
#define NUMERIC 1 /* Numeric digit (0-9). */
#define END_LIN 2 /* End-of-Line marker (cr or ;). */
#define COMMA 3 /* Field separator (,). */
#define OPERATR 4 /* Operator (* - GE < ( SHR etc.). */
#define BAS_DES 5 /* Base designator ($ % @). */
#define QUOTE 6 /* String delimiter (" '). */
#define TRASH 7
#define VALUE 8 /* Evaluated expression. */
#define TRASH 9
#define BLANK 10 /* White space (spc tab). */
#define TRASH 11 /* Other characters. */
/* Some tokens for composite operators: */
#define NO_OPR 0 /* No operator. */
#define GRTEQ 1 /* Greater than or equal to. */
#define NOTEQ 2 /* Not equal to. */
#define LESEQ 3 /* Less than or equal to. */
#define AND 4 /* And. */
#define OR 5 /* Or. */
#define XOR 6 /* Exclusive or. */
#define NOT 7 /* 1's complement. */
#define MOD 8 /* Mod--divide and return remainder. */
#define SHL 9 /* Shift left. */
#define SHR 10 /* Shift right. */
#define HIGH 11 /* High byte of. */
#define LOW 12 /* Low byte of. */
/* Operator precedence values: */
#define UOP1 0 /* Unary +, unary -. */
#define MULT 1 /* *, /, MOD, SHL, SHR. */
#define ADDIT 2 /* Binary +, binary -. */
#define RELAT 3 /* >, =, <, >=, <>, <=. */
#define UOP2 4 /* NOT. */
#define LOG1 5 /* AND. */
#define LOG2 6 /* OR, XOR. */
#define UOP3 7 /* HIGH, LOW. */
#define RPREN 8 /* ). */
#define LPREN 9 /* (. */
#define ENDEX 10 /* CR, ;, ,. */
#define START 11 /* Start of expression. */
/* Bits of opcode attribute byte. */
#define PSOP 0x80 /* Pseudo-op. */
#define DIROK 0x40 /* Non-pseudo-op is OK for direct addressing. */
#define IFGROUP 0x40 /* Pseudo-op is IF, ELSE, ENDI. */
/* Address modes for the 9900 instruction set */
#define WREG 0
#define INDIRECT 1
#define SYMBOLIC 2
#define INDEXED 3
#define AUTOINC 4
/* Misc control chars */
#define CPMEOF 0x1A
#define CTLS 19 /* Control S for stoppin */
#define CTLC 3 /* Control C aborts */
#define NOSORT TRUE /* Controls whether or not we want the table sorted */
#define SORT FALSE
struct diskbuf
{
int fd;
char *pointr;
char space[NSECT*128];
};
struct diskbuf sorbuf,lstbuf,hexbuf;
/* Set up the symbol table: */
struct symbtbl
{
char symname[SYMLEN];
unsigned symvalu;
};
struct symbtbl symtbl[SYMBOLS], *symend, *sympoint;
/* If stack and stack pointer. */
char ifsp;
unsigned ifstack[IFDEPTH+1];
/* Buffer to hold current line: */
char *linptr, linbuf[LINLEN];
/* Buffer to hold the code generated by a line. */
char nbytes, binbuf[255];
/* Buffers for the hex generator. */
char chksum, hxbytes, *hxlnptr, hxlnbuf[44];
/* Miscellanious mailboxes: */
char errcode; /* Error records. */
int errcount;
char evalerr; /* Flag to tell of error in eval. */
char backflg, oldattr; /* Item push-back buffer. */
unsigned oldvalu;
char curdrive; /* Place to save drive that was current
disk when assembly started. */
char hexflg; /* Flag for asmline to tell hex
generator what to do. */
char directok; /* All symbols on line pre-defined. */
unsigned pc; /* Assembly program counter. */
unsigned address; /* Address to be put into listed line. */
char pass; /* Which pass the assembly is in. */
char addrmode;
char quitflag; /* Used in eval to detect INDEXED expressions */
/* Some trivial functions: */
#define backchr linptr-- /* Push back a character. */